package com.hjimi.ski.view.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.hjimi.ski.R;
import com.hjimi.ski.utils.Mutils;
import com.hjimi.ski.utils.update.AllDialogShowStrategy;
import com.hjimi.ski.utils.update.NotificationDownloadCreatorMandatory;
import com.hjimi.ski.utils.update.NotificationUpdateCreatorMandatory;
import com.hjimi.ski.utils.update.OkhttpCheckWorker;
import com.hjimi.ski.utils.update.OkhttpDownloadWorker;
import com.hjimi.ski.utils.update.ToastCallback;
import org.lzh.framework.updatepluginlib.UpdateBuilder;

/**
 * Created By 孙岩
 * on 2023/2/17
 */
public class Splash1Activity extends Activity{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
//        upload();

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(Splash1Activity.this, UnBindActivity.class);
                startActivity(intent);
                Splash1Activity.this.finish();
            }
        }, 3000);
    }


    public void upload(){
        String mCurVersionName = Mutils.getLocalVersionName(this);
        int mCurVersionCode = Mutils.getLocalVersion(this);
        ToastCallback callback = new ToastCallback(this, new ToastCallback.ToastCallbackI() {
            @Override
            public void Failure(int type, String msg) {

            }

            @Override
            public void succeed(int type, String msg) {

            }
        });
        UpdateBuilder builder = UpdateBuilder.create();
        // 配置toast通知的回调
        builder.setDownloadCallback(callback);
        builder.setCheckCallback(callback);

        // 根据各项是否选择使用默认配置进行使用更新。
        builder.setCheckWorker(OkhttpCheckWorker.class);
        builder.setUpdateStrategy(new AllDialogShowStrategy());
        builder.setDownloadNotifier(new NotificationDownloadCreatorMandatory());
        builder.setCheckNotifier(new NotificationUpdateCreatorMandatory(builder, mCurVersionName, mCurVersionCode, new NotificationUpdateCreatorMandatory.NotificationUpdateCreatorI() {
            @Override
            public void onClick(int button) {
                if (button == 0) {

                }
            }

            @Override
            public void isNotMandatory() {//不是强制升级

            }
        }));
        builder.setDownloadWorker(OkhttpDownloadWorker.class);
        builder.check();
    }
}
